<?php
	include "../../public/commom/config.php";
	include "../lock2.php";
	
	date_default_timezone_set("PRC");
?>

<!DOCTYPE html>
<html>
	
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
	</head>
	
	<body>
		<div id="main">
			<h1>留言表</h1>
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>编号</th>
						<th>用户</th>
						<th>商品</th>
						<th>内容</th>
						<th>时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<?php
						$sql = "SELECT leaveword.*, user.username uname, shop.name sname FROM leaveword LEFT JOIN user ON (leaveword.user_id = user.id) LEFT JOIN shop ON (leaveword.shop_id = shop.id)";
					
						$result = mysqli_query($conn, $sql);
						
						while($row = mysqli_fetch_array($result)) {
							echo "<tr>
									<td>" . $row["id"] . "</td>
									<td>" . $row["uname"] . "</td>
									<td>" . $row["sname"] . "</td>
									<td>" . $row["content"] . "</td>
									<td>" . date("Y-m-d H-i-s", $row["time"]) . "</td>
									<td><a href='delete.php?id=" . $row["id"] . "'>删除</a></td>
								</tr>";
						} 
						
						mysqli_close($conn);
					?>
				</tbody>
				
			</table>
		</div>
	</body>
	
</html>